<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="${pageContext.request.contextPath}/css/common.css" rel="stylesheet" type="text/css"/>
<link href="${pageContext.request.contextPath}/css/cart.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.3.js"></script>
<script type="text/javascript">
//注：每个嵌入页必须定义该方法，供父窗口调用，并且返回true或false来告之父窗口是否关闭
function Ok(){

	//表单校验
	if(checkForm() == false){
		return;
	}
	
	//POST
	$("#addrForm").submit();
	
	//Jquery Dialog回调函数
	window.parent.JqueryDialog.SubmitCompleted("添加成功！", true, true);
}

// 二级联动菜单代码
$(document).ready(function(){
	$("#area").change(function(){
		$("#area option").each(function(i,o){
			if($(this).attr("selected")){
				$(".region").hide();
				$(".region").eq(i).fadeIn("fast");
			}
		});
	});
	$("#area").change();
});

function checkForm(){
	var $p1 = $("#p1");
	// 收货人非空校验
	var name = $("#name").val();
	if(name == null || name == ""){
		$p1.show();
		$p1.html("<span>收货人不能为空!<span>");
		return false;
	}
	// 小区非空校验
	var $region = $("#region");
	if($region.css("display") == "none"){
		$p1.show();
		$p1.html("<span>小区没有选择!<span>");
		return false;
	}	
	// 详细地址非空校验
	var addr = $("#addr").val();
	if(addr == null || addr == ""){
		$p1.show();
		$p1.html("<span>详细地址不能为空!<span>");
		return false;
	}
	// 电话非空校验
	var phone = $("#phone").val();
	if(phone == null || phone == ""){
		$p1.show();
		$p1.html("<span>手机号码不能为空!<span>");
		return false;
	}
}
</script>
</head>
<body>
<input id="oid" type="hidden" value="<s:property value="oid"/>"/>
<div class="container cart">
		<div class="span24">
				<form id="addrForm" action="${pageContext.request.contextPath }/address_insertAddrSubmit.action?isNoForward=1" method="post">
				<input type="hidden" name="isForward" value="0"/>
				<div class="span24">
                	<p id="p1" style="display:none;color:red;"></p>
					<table style="width: 51%;">
						<tbody >
							<tr>
								<td colspan="4" align="left" style="font-size:16px;">添加收货地址</td>
							</tr>
							<tr>
								<th width="30%">收货人:</th>
								<td>
									<input id="name" name="name" type="text" value="" style="width:150px" />
								</td>
							</tr>
							<tr>
								<th width="30%">所在小区:</th>
								<td>
									<select id="area" name="area">
			                        	<option >----网店服务区----</option>
			                        	<option value="东方名城">东方名城</option>
			                        </select>
			                        <select class="region">
			                        	<option value="0" selected="selected">----请选择小区----</option>
			                        </select>
			                        <select id="region" name="region" class="region">
			                        	<s:iterator var="r" value="regions">
			                        		<option value="<s:property value="#r.rname"/>"><s:property value="#r.rname"/></option>
			                        	</s:iterator>
			                        </select>
								</td>
							</tr>
							<tr>
								<th width="30%">详细地址:</th>
								<td>
									<input id="addr" name="addr" type="text" value="" style="width:150px" />
								</td>
							</tr>
							<tr>
								<th width="30%">手机号码:</th>
								<td>
									<input id="phone" name="phone" type="text" value="" style="width:150px" />
								</td>
							</tr>
						</tbody>
					</table>
				</div>
			</form>
		</div>
</div>
</body>
</html>
